<?php

namespace app\common\model;

use think\Db;
use think\Model;

class ExpressCooperate extends Model
{

    public $autoWriteTimestamp = "init";

    public $createTime = "createtime";

    public $updateTime = "updatetime";

    /**
     * 添加合作记录
     * @param $uid
     * @param $express_id
     * @return void
     */
    public static function setAdd($uid,$express_id)
    {
        $info = self::where("user_id",$uid)
            ->where("express_id",$express_id)
            ->find();
        if(!$info){
            self::create([
                "user_id"   => $uid,
                "express_id"=> $express_id,
                "num"       => 1
            ]);
        }else{
            $info->setInc("num");
        }
    }

}